﻿using Coolzon.UI.Core.Properties;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RT = Coolzon.Metadata.Runtime;

namespace Coolzon.UI.Core.Converters
{
    public class ResourceFileConverter : ValueConverter
    {
        public object Convert(ConvertContext context, RT.Property property)
        {
            ResourceFile resourceFile = new ResourceFile(property.ValueNode.GetAtrributeValue("Value"));
            return resourceFile;
        }

        public RT.ValueNode ConvertBack(ConvertContext context, object value, object dtTagData)
        {
            RT.ValueNode valueNode = new RT.ValueNode("String");
            valueNode.Attributes = new Dictionary<string, string>();
            valueNode.Attributes.Add("Value", value == null ? string.Empty : (value as ResourceFile).Path);
            return valueNode;
        }
    }
}
